package io;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author: jiafeim12345@163.com
 * @Date: 2018/3/29/029 20:39
 */
public class Demo {

  @Test
  public void testOne() throws Exception {
    int j = 0;
}

  @Test
  public void testTwo() throws IOException {
    FileChannel cha = new FileInputStream("C:\\Users\\Administrator\\Desktop\\代理模式.txt").getChannel();
    ByteBuffer bu = ByteBuffer.allocate(1024);
    cha.read(bu);
    bu.flip();
    while (bu.hasRemaining()) {
      System.out.print((char) bu.get());
    }
    cha.close();
  }

  @Test
  public void testThree() throws IOException {
    FileChannel cha = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\代理模式-read.txt").getChannel();
    ByteBuffer bu = ByteBuffer.allocate(10240);
    IntBuffer intBuffer = bu.asIntBuffer();
    intBuffer.put(1);
    intBuffer.put(3);
    System.out.println(intBuffer.get(1));
    cha.close();
  }

  @Test
  public void testFour() {
    short a = 1;
    a = (short) (a + 1);
    a += 1;
    System.out.println(a);
  }

  @Test
  public void testFive() {
    while (true) {

    }
  }

}
